<table class="table table-hover">
    <thead>
        <tr>
            <th width="5%"><input type="checkbox" class="grid-select-all" /></th>
            <th>订单号</th>
            <th>kol编号</th>
            <th>合作进度</th>
            <th>合作状态</th>
            <th class="th-nowrap">备注</th>
           {{-- <th class="th-nowrap">操作</th>--}}
        </tr>
    </thead>
    <tbody>
        @foreach($paginator as $row)
            <tr>
                <td><input type="checkbox" class="grid-row-checkbox" data-id="{{ $row->id }}" /></td>
                <td>{{ $row->order_no ?? '' }}</td>
                <td>{{ \App\Models\KolManage\Kol::getValueById($row->kol_id, 'kol_code') ?? ''}}</td>
                <td>{{ \App\Models\KolManage\KolOrder::$_cooperate_progress[$row->cooperate_progress] ?? ''}}</td>
                <td>{{ \App\Models\KolManage\KolOrder::$_cooperate_status[$row->cooperate_status] ?? ''}}</td>
                <td>
                    <a class="grid-editable-detail-remark" href="#"
                       data-type="text"
                       data-pk="{{ $row->id }}"
                       data-url="{{ '/xqc/kol-manage/kol-order/'.$row->id }}"
                       data-value="{{ $row->remark }}"> {{ $row->remark }}
                    </a>
                </td>
                {{--<td>
                    <a href="/xqc/kol-manage/kol-order/{{ $row->id }}/edit" class="grid-row-edit">
                        <i class="fa fa-edit"></i>
                    </a>
                </td>--}}
            </tr>
        @endforeach
    </tbody>
</table>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('.grid-row-checkbox').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChanged', function () {
            let id = $(this).data('id');
            if (this.checked) {
                $.admin.grid.select(id);
                $(this).closest('tr').css('background-color', '#ffffd5');
            } else {
                $.admin.grid.unselect(id);
                $(this).closest('tr').css('background-color', '');
            }
        }).on('ifClicked', function () {
            let id = $(this).data('id');
            if (this.checked) {
                $.admin.grid.unselect(id);
            } else {
                $.admin.grid.select(id);
            }
        });

        (function () {
            $('.grid-select-all').iCheck({checkboxClass:'icheckbox_minimal-blue'});
            $('.grid-select-all').on('ifChanged', function(event) {
                if (this.checked) {
                    $('.grid-row-checkbox').iCheck('check');
                } else {
                    $('.grid-row-checkbox').iCheck('uncheck');
                }
            }).on('ifClicked', function () {
                if (this.checked) {
                    $.admin.grid.selects = {};
                } else {
                    $('.grid-row-checkbox').each(function () {
                        let id = $(this).data('id');
                        $.admin.grid.select(id);
                    });
                }
            });
        })();


        //更新备注
        let _editable = function (name,showbuttons = false,mode = "inline") {
            $('.grid-editable-'+name).editable({
                "emptytext":"<i class=\"fa fa-pencil\"><\/i>",
                "showbuttons":showbuttons,
                "mode":mode,
                "name":name,
                success: function(response, newValue) {
                    if (typeof response === 'object') {
                        if (response.status) {
                            toastr.success(response.message);
                        } else {
                            swal(response.message, '', 'error');
                        }
                    }
                }
            });
        };
        _editable('detail-remark');

    });
</script>
